package com.glwan.fixedassetapp.Adapter;


import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.glwan.fixedassetapp.R;
import com.glwan.fixedassetapp.model.FragmentMenuModel;

import java.util.ArrayList;
import java.util.List;

public class HomeFragmentAdapter extends BaseAdapter {

    public List<FragmentMenuModel> menuList = new ArrayList<>();
    private LayoutInflater inflater;

    public HomeFragmentAdapter(Context context) {
        inflater = LayoutInflater.from(context);
//        menuList.add(new FragmentMenuModel(R.drawable.fragment_home_list, R.string.product_list));
        menuList.add(new FragmentMenuModel(R.drawable.fragment_home_task, R.string.inventoryTask));
//        menuList.add(new FragmentMenuModel(R.drawable.fragment_home_invent, R.string.inventory));
//        menuList.add(new FragmentMenuModel(R.drawable.fragment_home_chart, R.string.inventorySituation));
//        menuList.add(new FragmentMenuModel(R.drawable.fragment_home_storage, R.string.menu_storage));
//        menuList.add(new FragmentMenuModel(R.drawable.fragment_home_delivery, R.string.menu_delivery));
//        menuList.add(new FragmentMenuModel(R.drawable.fragment_home_import, R.string.dataImport));
//        menuList.add(new FragmentMenuModel(R.drawable.fragment_home_export, R.string.dataExport));

    }

    public HomeFragmentAdapter(Context context, List<FragmentMenuModel> menuList) {
        inflater = LayoutInflater.from(context);
        this.menuList.addAll(menuList);
    }

    @Override
    public int getCount() {
        return menuList.size();
    }

    @Override
    public Object getItem(int i) {
        return menuList.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        view = inflater.inflate(R.layout.fragment_home_menu, null);
        ImageView iv = view.findViewById(R.id.fragment_home_menu_icon);
        iv.setBackground(inflater.getContext().getDrawable(menuList.get(i).getIconId()));
        TextView tv = view.findViewById(R.id.fragment_home_menu_name);
        tv.setText(inflater.getContext().getString(menuList.get(i).getNameId()));
        return view;
    }
}
